﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsHoaDon
    {
        private double mDaThanhToan = 0.0;
        private int mDaXuatVatTu = 0;
        private string mDienGiai = "";
        private string mGioDen = "";
        private string mGioDi = "";
        private string mKhoa = "";
        private string mKhoaBan = "";
        private string mKhoaCa = "";
        private string mKhoaCaTao = "";
        private string mKhoaDoiTuong = "";
        private string mKhoaDoiTuongThue = "";
        private string mKhoaDonVi = "";
        private string mKhoaLoaiHoaDon = "";
        private string mKhoaNhanVien = "";
        private string mKhoaNhanVienSua = "";
        private string mKhoaPhuongThucTT = "";
        private string mKhoaQuay = "";
        private string mMaSoThue = "";
        private string mNamThang = "";
        private string mNgayChungTu = "";
        private string mNgayHoaDon = "";
        private string mNgayXuatHoaDon = "";
        private string mNguoiSuDung = "";
        private string mNguoiTao = "";
        private int mNoHoaDon = 0;
        private int mSend = 0;
        private string mSoChungTu = "";
        private string mSoHoaDon = "";
        private int mSoLanIn = 0;
        private int mSoLuongKhach = 0;
        private string mSoSeri = "";
        private string mSoTheVIP = "";
        private string mTenDoiTuongThue = "";
        private double mTienChietKhau = 0.0;
        private double mTienCoc = 0.0;
        private double mTienDichVu = 0.0;
        private double mTienHang = 0.0;
        private double mTienThue = 0.0;
        private string mTinhTrang = "";
        private double mTongThanhToan = 0.0;
        private int mTyLeChietKhau = 0;
        private int mTyLeThue = 0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                string commandText = "SELECT * FROM DM_ChiPhi WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, commandParameters);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mNamThang = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaQuay = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mKhoaBan = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVien = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuong = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongThue = Conversions.ToString(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetString));
                    this.mTenDoiTuongThue = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetString));
                    this.mSoSeri = Conversions.ToString(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetString));
                    this.mSoHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetString));
                    this.mNgayHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetString));
                    this.mTyLeThue = Conversions.ToInteger(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienChietKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienHang = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienDichVu = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetDecimal));
                    this.mTongThanhToan = Conversions.ToDouble(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetDecimal));
                    this.mDaThanhToan = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetDecimal));
                    this.mTinhTrang = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetString));
                    this.mNguoiSuDung = Conversions.ToString(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetString));
                    this.mSoLuongKhach = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetInt32));
                    this.mGioDen = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1a, modGeneral.typeOfColumn.GetString));
                    this.mGioDi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1b, modGeneral.typeOfColumn.GetString));
                    this.mSoLanIn = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x1c, modGeneral.typeOfColumn.GetInt32));
                    this.mKhoaPhuongThucTT = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1d, modGeneral.typeOfColumn.GetString));
                    this.mKhoaCa = Conversions.ToString(modGeneral.GetValue(dataReader, 30, modGeneral.typeOfColumn.GetString));
                    this.mNguoiTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1f, modGeneral.typeOfColumn.GetString));
                    this.mKhoaCaTao = Conversions.ToString(modGeneral.GetValue(dataReader, 0x20, modGeneral.typeOfColumn.GetString));
                    this.mNoHoaDon = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x21, modGeneral.typeOfColumn.GetInt32));
                    this.mSoTheVIP = Conversions.ToString(modGeneral.GetValue(dataReader, 0x22, modGeneral.typeOfColumn.GetString));
                    this.mKhoaNhanVienSua = Conversions.ToString(modGeneral.GetValue(dataReader, 0x23, modGeneral.typeOfColumn.GetString));
                    this.mTienCoc = Conversions.ToDouble(modGeneral.GetValue(dataReader, 0x24, modGeneral.typeOfColumn.GetDecimal));
                    this.mDaXuatVatTu = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x25, modGeneral.typeOfColumn.GetInt32));
                    this.mNgayXuatHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x26, modGeneral.typeOfColumn.GetString));
                    this.mTyLeChietKhau = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x27, modGeneral.typeOfColumn.GetInt32));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 40, modGeneral.typeOfColumn.GetString));
                    this.mSend = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x29, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag2;
            IDataParameter[] commandParameters = new IDataParameter[0x2a];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@NamThang", DbType.Int64, ParameterDirection.Input, this.mNamThang);
                commandParameters[2] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[3] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[4] = DBHelper.createParameter("@KhoaQuay", DbType.Int64, ParameterDirection.Input, this.mKhoaQuay);
                commandParameters[5] = DBHelper.createParameter("@KhoaBan", DbType.Int64, ParameterDirection.Input, this.mKhoaBan);
                commandParameters[6] = DBHelper.createParameter("@KhoaNhanVien", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVien);
                commandParameters[7] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuong);
                commandParameters[8] = DBHelper.createParameter("@KhoaDoiTuongThue", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongThue);
                commandParameters[9] = DBHelper.createParameter("@TenDoiTuongThue", DbType.Int64, ParameterDirection.Input, this.mTenDoiTuongThue);
                commandParameters[10] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[11] = DBHelper.createParameter("@KhoaLoaiHoaDon", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiHoaDon);
                commandParameters[12] = DBHelper.createParameter("@SoSeri", DbType.Int64, ParameterDirection.Input, this.mSoSeri);
                commandParameters[13] = DBHelper.createParameter("@SoHoaDon", DbType.Int64, ParameterDirection.Input, this.mSoHoaDon);
                commandParameters[14] = DBHelper.createParameter("@NgayHoaDon", DbType.Int64, ParameterDirection.Input, this.mNgayHoaDon);
                commandParameters[15] = DBHelper.createParameter("@TyLeThue", DbType.Double, ParameterDirection.Input, this.mTyLeThue);
                commandParameters[0x10] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[0x11] = DBHelper.createParameter("@TienChietKhau", DbType.Date, ParameterDirection.Input, this.mTienChietKhau);
                commandParameters[0x12] = DBHelper.createParameter("@TienHang", DbType.Date, ParameterDirection.Input, this.mTienHang);
                commandParameters[0x13] = DBHelper.createParameter("@TienDichVu", DbType.Date, ParameterDirection.Input, this.mTienDichVu);
                commandParameters[20] = DBHelper.createParameter("@TongThanhToan", DbType.Date, ParameterDirection.Input, this.mTongThanhToan);
                commandParameters[0x15] = DBHelper.createParameter("@DaThanhToan", DbType.Date, ParameterDirection.Input, this.mDaThanhToan);
                commandParameters[0x16] = DBHelper.createParameter("@TinhTrang", DbType.Int64, ParameterDirection.Input, this.mTinhTrang);
                commandParameters[0x17] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                commandParameters[0x18] = DBHelper.createParameter("@NguoiSuDung", DbType.Int64, ParameterDirection.Input, this.mNguoiSuDung);
                commandParameters[0x19] = DBHelper.createParameter("@SoLuongKhach", DbType.Double, ParameterDirection.Input, this.mSoLuongKhach);
                commandParameters[0x1a] = DBHelper.createParameter("@GioDen", DbType.Int64, ParameterDirection.Input, this.mGioDen);
                commandParameters[0x1b] = DBHelper.createParameter("@GioDi", DbType.Int64, ParameterDirection.Input, this.mGioDi);
                commandParameters[0x1c] = DBHelper.createParameter("@SoLanIn", DbType.Double, ParameterDirection.Input, this.mSoLanIn);
                commandParameters[0x1d] = DBHelper.createParameter("@KhoaPhuongThucTT", DbType.Int64, ParameterDirection.Input, this.mKhoaPhuongThucTT);
                commandParameters[30] = DBHelper.createParameter("@KhoaCa", DbType.Int64, ParameterDirection.Input, this.mKhoaCa);
                commandParameters[0x1f] = DBHelper.createParameter("@NguoiTao", DbType.Int64, ParameterDirection.Input, this.mNguoiTao);
                commandParameters[0x20] = DBHelper.createParameter("@KhoaCaTao", DbType.Int64, ParameterDirection.Input, this.mKhoaCaTao);
                commandParameters[0x21] = DBHelper.createParameter("@NoHoaDon", DbType.Double, ParameterDirection.Input, this.mNoHoaDon);
                commandParameters[0x22] = DBHelper.createParameter("@SoTheVIP", DbType.Int64, ParameterDirection.Input, this.mSoTheVIP);
                commandParameters[0x23] = DBHelper.createParameter("@KhoaNhanVienSua", DbType.Int64, ParameterDirection.Input, this.mKhoaNhanVienSua);
                commandParameters[0x24] = DBHelper.createParameter("@TienCoc", DbType.Date, ParameterDirection.Input, this.mTienCoc);
                commandParameters[0x25] = DBHelper.createParameter("@DaXuatVatTu", DbType.Double, ParameterDirection.Input, this.mDaXuatVatTu);
                commandParameters[0x26] = DBHelper.createParameter("@NgayXuatHoaDon", DbType.Int64, ParameterDirection.Input, this.mNgayXuatHoaDon);
                commandParameters[0x27] = DBHelper.createParameter("@TyLeChietKhau", DbType.Double, ParameterDirection.Input, this.mTyLeChietKhau);
                commandParameters[40] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x29] = DBHelper.createParameter("@Send", DbType.Double, ParameterDirection.Input, this.mSend);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "sp_HoaDonBanHang", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public double DaThanhToan
        {
            get
            {
                return this.mDaThanhToan;
            }
            set
            {
                this.mDaThanhToan = value;
            }
        }

        public int DaXuatVatTu
        {
            get
            {
                return this.mDaXuatVatTu;
            }
            set
            {
                this.mDaXuatVatTu = value;
            }
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string GioDen
        {
            get
            {
                return this.mGioDen;
            }
            set
            {
                this.mGioDen = value;
            }
        }

        public string GioDi
        {
            get
            {
                return this.mGioDi;
            }
            set
            {
                this.mGioDi = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaBan
        {
            get
            {
                return this.mKhoaBan;
            }
            set
            {
                this.mKhoaBan = value;
            }
        }

        public string KhoaCa
        {
            get
            {
                return this.mKhoaCa;
            }
            set
            {
                this.mKhoaCa = value;
            }
        }

        public string KhoaCaTao
        {
            get
            {
                return this.mKhoaCaTao;
            }
            set
            {
                this.mKhoaCaTao = value;
            }
        }

        public string KhoaDoiTuong
        {
            get
            {
                return this.mKhoaDoiTuong;
            }
            set
            {
                this.mKhoaDoiTuong = value;
            }
        }

        public string KhoaDoiTuongThue
        {
            get
            {
                return this.mKhoaDoiTuongThue;
            }
            set
            {
                this.mKhoaDoiTuongThue = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaLoaiHoaDon
        {
            get
            {
                return this.mKhoaLoaiHoaDon;
            }
            set
            {
                this.mKhoaLoaiHoaDon = value;
            }
        }

        public string KhoaNhanVien
        {
            get
            {
                return this.mKhoaNhanVien;
            }
            set
            {
                this.mKhoaNhanVien = value;
            }
        }

        public string KhoaNhanVienSua
        {
            get
            {
                return this.mKhoaNhanVienSua;
            }
            set
            {
                this.mKhoaNhanVienSua = value;
            }
        }

        public string KhoaPhuongThucTT
        {
            get
            {
                return this.mKhoaPhuongThucTT;
            }
            set
            {
                this.mKhoaPhuongThucTT = value;
            }
        }

        public string KhoaQuay
        {
            get
            {
                return this.mKhoaQuay;
            }
            set
            {
                this.mKhoaQuay = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public string NamThang
        {
            get
            {
                return this.mNamThang;
            }
            set
            {
                this.mNamThang = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string NgayHoaDon
        {
            get
            {
                return this.mNgayHoaDon;
            }
            set
            {
                this.mNgayHoaDon = value;
            }
        }

        public string NgayXuatHoaDon
        {
            get
            {
                return this.mNgayXuatHoaDon;
            }
            set
            {
                this.mNgayXuatHoaDon = value;
            }
        }

        public string NguoiSuDung
        {
            get
            {
                return this.mNguoiSuDung;
            }
            set
            {
                this.mNguoiSuDung = value;
            }
        }

        public string NguoiTao
        {
            get
            {
                return this.mNguoiTao;
            }
            set
            {
                this.mNguoiTao = value;
            }
        }

        public int NoHoaDon
        {
            get
            {
                return this.mNoHoaDon;
            }
            set
            {
                this.mNoHoaDon = value;
            }
        }

        public int Send
        {
            get
            {
                return this.mSend;
            }
            set
            {
                this.mSend = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public string SoHoaDon
        {
            get
            {
                return this.mSoHoaDon;
            }
            set
            {
                this.mSoHoaDon = value;
            }
        }

        public int SoLanIn
        {
            get
            {
                return this.mSoLanIn;
            }
            set
            {
                this.mSoLanIn = value;
            }
        }

        public int SoLuongKhach
        {
            get
            {
                return this.mSoLuongKhach;
            }
            set
            {
                this.mSoLuongKhach = value;
            }
        }

        public string SoSeri
        {
            get
            {
                return this.mSoSeri;
            }
            set
            {
                this.mSoSeri = value;
            }
        }

        public string SoTheVIP
        {
            get
            {
                return this.mSoTheVIP;
            }
            set
            {
                this.mSoTheVIP = value;
            }
        }

        public string TenDoiTuongThue
        {
            get
            {
                return this.mTenDoiTuongThue;
            }
            set
            {
                this.mTenDoiTuongThue = value;
            }
        }

        public double TienChietKhau
        {
            get
            {
                return this.mTienChietKhau;
            }
            set
            {
                this.mTienChietKhau = value;
            }
        }

        public double TienCoc
        {
            get
            {
                return this.mTienCoc;
            }
            set
            {
                this.mTienCoc = value;
            }
        }

        public double TienDichVu
        {
            get
            {
                return this.mTienDichVu;
            }
            set
            {
                this.mTienDichVu = value;
            }
        }

        public double TienHang
        {
            get
            {
                return this.mTienHang;
            }
            set
            {
                this.mTienHang = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public string TinhTrang
        {
            get
            {
                return this.mTinhTrang;
            }
            set
            {
                this.mTinhTrang = value;
            }
        }

        public double TongThanhToan
        {
            get
            {
                return this.mTongThanhToan;
            }
            set
            {
                this.mTongThanhToan = value;
            }
        }

        public int TyLeChietKhau
        {
            get
            {
                return this.mTyLeChietKhau;
            }
            set
            {
                this.mTyLeChietKhau = value;
            }
        }

        public int TyLeThue
        {
            get
            {
                return this.mTyLeThue;
            }
            set
            {
                this.mTyLeThue = value;
            }
        }
    }
}

